
import * as PIXI from 'pixi.js';
import Image from 'components/image';
import {findGameApp} from 'common/utils';
const { Container } = PIXI;


export default class Progress {
  constructor({parent, ...props}) {
    this.parent = parent;
    this.container = new Container();

    const { view } = window.CFG;
    const { bgSrc, src } = props;

    let bg = new Image({src: bgSrc, width: view.width, height: view.height, left: 0, top: 0});
    // let rule = new Image({src, width: 635, height: 1019, top: (view.height - 1019) / 2, left: (view.width - 635) / 2});

    bg.interactive = true;
    bg.on('tap', (e) => {
      e.stopped = true;
    });

    this.container.addChild(bg);
    // this.container.addChild(rule);

    this._renderCloseBtn(props);

  }

  _renderCloseBtn = (data) => {
    const { closeSize: {height, left, top, width}, onClose = () => {}, closeSrc } = data;
    const { view } = window.CFG;

    let closeImg = new Image({
      src: closeSrc,
      width,
      height,
      left,
      top: 80,
    });

    closeImg.interactive = true;
    closeImg.on('tap', () => {
      onClose();
    });

    this.container.addChild(closeImg);

  }

}
